package com.juzipi.demo.io;

import java.io.IOException;
import java.net.Socket;


//IO编程客户端
public class MyClient {

    public static void main(String[] args) {

        for (int i = 1; i <= 10; i++) {
            new ClientDemo().start();
        }



    }
    static class ClientDemo extends Thread {



        @Override
        public void run() {
            try {
                Socket socket = new Socket("127.0.0.1",9898);
                int i = 0;
                while (true){

                    socket.getOutputStream().write(("测试数据:"+i).getBytes());
                    socket.getOutputStream().flush();

                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    i++;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
